home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
exits.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-09
|
5KB
|
179 lines
/*
* @(#) exits.c 12.1 95/05/09 SCOINC
*/
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* SCCS Stuff
*
* @(#) exits.c 12.1 95/05/09 SCOINC
*
* Moification History
*
# S002, 25-May-93, rickra
# Added these includes:
* #include <X11/Intrinsic.h>
* #include "include/unixincs.h"
* #include "include/buttons.h"
*
# S001, 01-Jan-93, rickra
# Added externs:
* abort();
* disp_msg();
* exit();
*
# S000, 30-Sep-92, rickra
# Change hard coded color referneces to user configurable.
*/
/*+-------------------------------------------------------------------------
exits.c - XSW exit processor
wht@n4hgf.Mt-Park.GA.US
Defined functions:
adb_trap()
caught_signal(sig)
leave(exit_code)
leave_text(text,exit_code)
leaving()
--------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:09-25-1990-19:48-wht@n4hgf-leaving() go bang if X not initialized */
/*:09-25-1990-05:11-wht@n4hgf-release heh-heh x0.22 preliminary */
/*:09-20-1990-00:09-wht@n4hgf-scales, sysinfo/minfo, bootinfo working */
/*:09-15-1990-06:08-wht-creation */
#include <stdio.h>
#include <signal.h>
#include <X11/Intrinsic.h>
#include "include/unixincs.h"
#include "include/buttons.h"
#include "include/xsw.h"
extern void abort ();
extern void disp_msg (unsigned long, char *);
extern int exit (int);
/*+-------------------------------------------------------------------------
leaving() - perform leave() basic processing and return
--------------------------------------------------------------------------*/
void
leaving ()
{
if (window)
{
XDestroyWindow (display, window);
XCloseDisplay (display);
}
} /* end of leaving */
/*+-------------------------------------------------------------------------
leave(exit_code) - leave program with exit code
--------------------------------------------------------------------------*/
void
leave (exit_code)
int exit_code;
{
leaving ();
#ifdef TESTING
gct_writelog ("xswLOG");
#endif
exit (exit_code);
} /* end of leave */
/*+-------------------------------------------------------------------------
leave_text(text,exit_code) - leave program with message and exit code
If exit_code == 255, do wperror
--------------------------------------------------------------------------*/
void
leave_text (text, exit_code)
char *text;
int exit_code;
{
fputs ("\nxsw: ", stdout);
if (text && *text)
{
if (window)
disp_msg (colorDisplayMsg.pixel, text);
fputs (text, stdout);
fputs ("\n", stdout);
}
if (exit_code == 255)
{
extern int errno;
extern int sys_nerr;
extern char *sys_errlist[];
if (errno < sys_nerr)
printf ("system-provided error status: %s\n", sys_errlist[errno]);
}
leave (exit_code);
} /* end of leave_text */
/*+-------------------------------------------------------------------------
adb_trap() - convenient trap for catching abort
Get a look at stack before abort() botches it
--------------------------------------------------------------------------*/
#if defined(ADB_DEBUG)
void
adb_trap ()
{
printf ("too bad .... goodbye\n");
} /* end of adb_trap */
#endif
/*+-------------------------------------------------------------------------
caught_signal(sig) - SIGHUP thru SIGSYS: leave with possible abort
--------------------------------------------------------------------------*/
void
caught_signal (sig)
int sig;
{
leaving ();
switch (sig)
{
case SIGQUIT:
case SIGILL:
case SIGTRAP:
case SIGIOT:
case SIGEMT:
case SIGFPE:
case SIGBUS:
case SIGSEGV:
case SIGSYS:
#if defined(ADB_DEBUG)
adb_trap (); /* if debugging, stop at convenient
* breakpoint */
#endif
abort ();
}
#ifdef TESTING
gct_writelog ("xswLOG");
#endif
exit (128 + sig);
} /* end of caught_signal */
/* vi: set tabstop=4 shiftwidth=4: */
/* end of exits.c */